#ifndef __LANE_CMD_PARSE_FN_H
#define __LANE_CMD_PARSE_FN_H

#include "uv.h"
#include "pal/lane_cmd_parse.h"
#include "pal/lane_control.h"
#include <stdbool.h>
typedef struct
{
    size_t reserveLen;
    uint8_t reserveBuf[1024 * 2];
    bool isReserve;
} ReserveFrameT;

#define LANE_RESPON_CRC_CAL(basePtr, type) crc((uint8_t *)basePtr + CRC_BASE_ADDR(type), sizeof(type) - MEM_SIZE(type, crc) - MEM_SIZE(type, head))

bool checkLen(head_t *head, uint16_t frame_len);
bool checkCrc(head_t *head, uint16_t recvLen);
uint16_t getFrameLen(head_t *head);
uint16_t howManyFrame(const uv_buf_t *buf, ssize_t len);
head_t *headForwardPoint(head_t *head, uint16_t forwardLen);

void handleRegisterCmd(respon_registration_t *reg);
void handleHeartBeatCmd(respon_heart_beat_t *heart_beat_result);
void handleFileBlockFrameCmd(file_block_frame_t *pack, uint16_t recvLen);
void handlePicUploadRecvCmd(respon_pic_block_recv_t *picResult);
void handleCalibrationRecvCmd(respon_calibration_t *calibration_result);
void handleCalibrationRecvCmdV2(respon_calibration_v2_t *calibration_result);

void initReserveFrame();
ReserveFrameT *getReserveFrame();

#endif